#!/bin/bash

#------------------------------------------------------------------------------
#Filename:	74820-tar2.sh
#Version:	1.1
#Date:	        2013/08/06
#Author:	yuanhui.shi
#Email:	        yuanhui.shi@cs2c.com.cn
#Summary:	02.01系统核心功能-06基础命令行工具-16tar工具-03tar程序压缩文件
#Notes:	        检验tar解压缩命令
#Copyright:	China Standard Software Co.,Ltd.
#History:
#	        Version 1.0,2013/08/06
#	        -The first one
#	        Version 1.1,2013/09/09
#	        -Modify the script to satisfy the shell standard
#------------------------------------------------------------------------------


PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

source ../../lib/Echo.sh

function CleanData ()
{
  rm -rf test
  rm -rf test.tar
  rm -rf test.tar.gz
  rm -rf test.tar.bz2
  EchoInfo "74820-tar2.sh执行完毕"
}

trap "CleanData" EXIT

echo "hello!" > test

EchoInfo "检验tar命令解压缩是否成功，参数是xvf，此时可以解压缩.tar文件"
tar cvf test.tar  test &>/dev/null
tar xvf test.tar &>/dev/null

test "`cat test`" == "hello!" 
EchoResult "tar命令解压缩可用"


EchoInfo "检验tar命令解压缩是否成功，参数是zxvf，此时可以解压缩.tar.gz文件"
tar zcvf test.tar.gz  test &>/dev/null
tar zxvf test.tar.gz &>/dev/null

test "`cat test`" == "hello!" 
EchoResult "tar命令解压缩可用"


EchoInfo "检验tar命令解压缩是否成功，参数是jxvf，此时可以解压缩.tar.bz2文件"
tar jcvf test.tar.bz2  test &>/dev/null
tar jxvf test.tar.bz2 &>/dev/null

test "`cat test`" == "hello!" 
EchoResult "tar命令解压缩可用"


